const tbody=document.querySelector('#shop-tbody')
const username=utils.getCookie('name')
if(username){
    getData()
}else{
    var btn=document.querySelector('#btn_add1')
    console.log(btn)
    btn.setAttribute('disabled','disabled')
}
function getData(){
    utils.fetch('./api/shop/select.php').then(resp=>{
        if(resp.code==200){
            //ES6解构赋值写法
            const {list}=resp.body
            //相当于const list=resp.body.list
            let html=''
            list.forEach((shop,index)=>{
                html += `
                    <tr data-id="${shop.id}">
                        <td><span>${index+1}</span></td>
                        <td><span>${shop.name}</span><input class="inputName" type="text"></td>
                        <td><span>${shop.price}</span><input class="inputPrice" type="text"></td>
                        <td><span>${shop.num}</span><input class="inputNum" type="text"></td>
                        <td >
                            <button class="btn btn-info btn-xs btn-edit">编辑</button>
                            <button class="btn btn-danger btn-xs btn-del">删除</button>
                            <button class="btn btn-success btn-xs btn-yes">确定</button>
                            <button class="btn btn-warning btn-xs btn-no">取消</button>
                        </td>
                    </tr>
                `
            })
            tbody.innerHTML=html

        }
    })
}